package edu.cuc.learningAkka.chap2;

import akka.actor.AbstractActor;
import akka.actor.ActorRef;
import akka.actor.Status;
import akka.japi.pf.ReceiveBuilder;
import scala.PartialFunction;

/**
 * Created by bingruiqi on 2017/9/9.
 */
public class JavaPongActor extends AbstractActor {
    @Override
    public PartialFunction receive() {
        return ReceiveBuilder.matchEquals("ping", s -> sender().tell("pong", ActorRef.noSender()))
                .matchAny(x -> sender().tell(new Status.Failure(new Exception("unknown message")), self())).build();
    }

}
